//
//  SWMusicsFetchReq.swift
//  ChildStory
//
//  Created by linhan on 2016/12/6.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation
class SWMusicsFetchReq: SWBaseRequest
{
    var categoryID:Int = 0
    var count:Int = 0
    var index:Int = 0
    
    override init()
    {
        super.init()
        api = SWRequestAPI.MusicsFetch
    }
    
    override var params:Any?
    {
        return ["typeId":categoryID, "index":index, "size":count]
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        return Mapper<SWMusicsFetchRsp>().map(JSONString: JSONString)
    }
}

class SWMusicsFetchRsp: NSObject,Mappable
{
    var code:String?
    var musics:[SWMusicRsp]?
    var hasNextPage:Bool?
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        code        <- map["Status"]
        musics      <- map["BaseModle.list"]
        hasNextPage <- map["BaseModle.hasNextPage"]
    }
}

class SWMusicRsp: NSObject,Mappable
{
    var id:Int?
    var name:String?
    var artist:String?
    var thumbURL:String?
    var coverURL:String?
    var musicURL:String?
    var durationString:String?
    
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        id         <- map["musicId"]
        name       <- map["name"]
        artist     <- map["author"]
        coverURL   <- map["cover"]
        thumbURL   <- map["defaultImg"]
        musicURL   <- map["linkUrl"]
        durationString   <- map["duration"]
    }
}
